﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoreApp
{
    public class StubStore:IStore
    {
        public StubStore(IPaySystem paySystem)
        {
            Items = new List<Item>();
        }
        public void Insert(Item item)
        {
            if (item == null)
                throw new NullReferenceException("book");
            Items.Add(item);
        }

        public int Count()
        {
            return Items.Count();
        }

        public List<Item> Items { get; private set; }

        public IPaySystem PaySystem { get; private set; }

        public void Sale(Item item)
        {
            if (item == null) throw new ArgumentNullException("item");

            if (item.Price < 0) throw new ArgumentOutOfRangeException("item < 0");

            if (!Items.Remove(item))
                throw new Exception("Item is not find");
        }
    }
}
